package com.zzuisa.sell.utils;

import com.zzuisa.sell.enums.CodeEnum;

/**
 * @ClassName EnumUtil
 * @Description TODO
 * @Author SunAo
 * @Date 2018/8/21 下午7:15
 * @Version 1.0
 */
public class EnumUtil {
    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }

}
